<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box {
            font-size: 20px;
            font-family: monospace;
            /* 1ch 代表0的宽度  */
            width: 0ch;
            white-space: nowrap;
            /* animation: move 4s linear  forwards; */
            /* steps 就是分几步来完成动画，有了 steps 不要写ease linear了 */
            animation: move 4s steps(9) forwards;
            overflow: hidden;
        }

        @keyframes move {
            0% {
            }
            100% {
                width: 18ch;
            }
        }
    </style>
</head>

<body>
<div id="box" class='box'>打字机效果,打字机效果hello world</div>
</body>

<script>
    const html = document.getElementById("box")
    console.log(html)


    this.htmlContent = `上面的字符串`


    let doc = new DOMParser().parseFromString(this.htmlContent, "text/xml") // 转换 string -> dom 对象
    let linkDomList = doc.querySelector('div').children  // 用 element API 获取其中的 pre 标签内的对象
    console.log("linklist:",linkDomList)
    for (let i = 0; i < linkDomList.length; i++) { // 遍历这个 children 并输出
        console.log(linkDomList[i])
    }



</script>
</html>
